<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>学员支付查询</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<script type="text/javascript" src="../../js/validata.js"></script>
<script type="text/javascript" src="../../js/jquery-ui/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
</head>
<body>
	<form id="form1">
		<table class="table table-bordered" id="datas">
			<tr>
				<td>培训机构:</td>
				<td id="school"></td>
			</tr>
			<tr>
				<td>距离练车时间:</td>
				<td id="time"></td>
			</tr>
			<tr>
				<td>违约金百分比:</td>
				<td>
					<input type="text" id="proportion" readonly="readonly"/>
				</td>
			</tr>
			<tr>
			<td colspan="2">
				<div id="slider"></div>
				<input type="hidden" id="id" name="id"/>
				<input type="hidden"  name="proportion" id="proportions"/>
			</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;">
					<button type="button" onclick="update();" class="btn btn-info">修改</button>
				</td>
			</tr>
		</table>
	</form>
	
    <script type="text/javascript">
    	var href = location.href.split("=");
		var penaltyMoneyId = href[1];
		getPenaltyMoneyById(penaltyMoneyId);
		$( "#slider" ).slider({
	      	range: "min",
	      	min: 0,
	      	max: 100,
	      	slide: function( event, ui ) {
	        	$( "#proportion" ).val( ui.value + "%");
	        	$( "#proportions" ).val( ui.value);
	      	}
		}); 
    	function getPenaltyMoneyById(id){
    		$.ajax({
    			url : "../../penaltyMoney/get.ao",
    			type : 'POST',
    			data : {
    				"id" : id
    			}, 
    			beforeSend : ajaxstar,
    			complete : ajaxend,
    			cache : false,
    			dataType : "json",
    			success : function(data) {
    				if (data["state"] == "success") {
    					$("#form1").find("td").each(function(){
    						var id = $(this).attr("id");
    						if(id != null && typeof(id) != "undefined"){
    							$(this).html(data["result"][id]);
    						}
    					});
    					$("#form1").find("input").each(function(){
    						var id = $(this).attr("id");
    						if(id != null && typeof(id) != "undefined"){
    							$(this).val(data["result"][id]);
    						}
    					});
    					$( "#slider" ).slider({
    				      	range: "min",
    				      	value:$("#proportions").val() ,
    				      	min: 0,
    				      	max: 100,
    					});
    				} else {
    					sAlert(data["result"]);
    				}
    			}
    		});
    	}
    	
    	function update(){
    		if(validata("form1")){
    			$.ajax({
    				url : "../../penaltyMoney/update.ao",
    				type : 'POST',
    				data : $("#form1").serialize(),
    				cache : false,
    				dataType : "json",
    				success : function(data){
    					sAlert(data["result"]);
    					if(data["state"] == "success"){
    						location.reload();
    						window.parent.searchPage(1,10);
    					}
    				}
    			});
    		}
    	}
    	
    </script>
</body>
</html>